package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.common.base.facade.pojo.PageResult;
import com.econ.powercloud.ems.pojo.EmsDeviceLocationVO;
import com.econ.powercloud.ems.pojo.EmsDeviceVO;
import com.econ.powercloud.ems.service.biz.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by rh on 2021/9/27 13:47
 *实时数据曲线
 */
@RestController
@Api(tags ="实时数据曲线")
@RequestMapping(value = "/api/v2/emsIntelligenceManager")
public class RealDataCurveController extends ApiBaseController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 实时数据曲线设备树接口
     * @param stationId
     * @return
     */
    @GetMapping(value = "getDeviceTree")
    @ApiOperation(value="实时数据曲线设备树接口", notes="实时数据曲线设备树接口")
    @ApiImplicitParam(name = "stationId", value = "储能站id", required = true, dataType = "String")
    public MsgResult<List<EmsDeviceVO>> getDeviceTree(@RequestParam(value = "stationId") String stationId) {
        return successHandler(deviceService.queryDeviceTree(stationId));
    }

    /**
     * 实时数据曲线模糊查询接口
     * @param deviceCode
     * @param analogType
     * @param remark
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "getDeviceDit")
    @ApiOperation(value="实时数据曲线模糊查询接口", notes="实时数据曲线模糊查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "deviceCode", value = "设备编码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "analogType", value = "数据类型", dataType = "Integer"),
            @ApiImplicitParam(name = "remark", value = "说明", dataType = "String"),
            @ApiImplicitParam(name = "pageNo", value = "页", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "行", required = true, dataType = "Integer")
    })
    public MsgResult<PageResult<List<EmsDeviceLocationVO>>> getDeviceDitList(@RequestParam("deviceCode")String deviceCode,
                                                                             @RequestParam(value = "analogType",required = false)Integer analogType,
                                                                             @RequestParam(value = "remark",required = false)String remark,
                                                                             @RequestParam("pageNo")Integer pageNo,
                                                                             @RequestParam("pageSize")Integer pageSize){
        return successHandler(deviceService.queryYcListByDeviceCodeAndTypeAndRemark(deviceCode, analogType, remark, pageNo, pageSize));
    }

    /**
     * 实时数据曲线数据查询接口
     * @param pid:点号
     * @param initDeviceCode: 根设备id,可以从实时数据曲线模糊查询接口获取
     * @return
     */
    @GetMapping(value = "getDitValue")
    @ApiOperation(value="实时数据曲线数据查询接口", notes="实时数据曲线数据查询接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pid", value = "点号id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "initDeviceCode", value = "跟设备id", required = true, dataType = "String")
    })
    public MsgResult getDitValue(@RequestParam("pid")String pid,
                                 @RequestParam("initDeviceCode")String initDeviceCode){
        return successHandler(deviceService.getDitValue(pid, initDeviceCode));
    }

}
